/*
 * @Author: LAPTOP-T83C393D\86159 15933331948@163.从m
 * @Date: 2023-09-13 22:21:36
 * @LastEditors: sichuntian sichuntian@smartmappingtek.com
 * @LastEditTime: 2024-05-14 11:06:41
 * @Description:
 *
 */
const config = require("../config/index")
const mongoose = (mongoose) => {
  mongoose.connect(`mongodb://${config.mongo.user}:${config.mongo.password}@${config.mongo.ip}:${config.mongo.port}/low_monitor?authSource=admin`, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })
  mongoose.connection.on("error", function (error) {
    console.log("数据库连接失败：" + error)
  })

  mongoose.connection.on("open", function () {
    console.log("数据库连接成功")
  })

  mongoose.connection.on("disconnected", function () {
    console.log("数据库连接断开")
  })

  mongoose.set("useFindAndModify", false)
}
//将配置导出
module.exports = {
  mongoose: mongoose,
}
